import { NestFactory } from '@nestjs/core';
import {VersioningType } from '@nestjs/common'
import { AppModule } from './app.module';
import { NestExpressApplication } from '@nestjs/platform-express'
// 会话存储
import * as session from 'express-session'
import { join } from 'path';
// 全局设置中间件
function resquestFn(req,res,next){
  // console.log(res)
  next()
}
async function bootstrap() {
  // 增加NestExpressApplication类型后，提示会更全
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  // 获取图片时设置的路由
  app.useStaticAssets(join(__dirname,'images'),{
    prefix:'/getFile'
  })
  // 版本控制
  app.enableVersioning({type:VersioningType.URI})
  app.use(session({secret:'zhaoqian',rolling:true,name:'zq',cookie:{maxAge:10000}}))
  app.use(resquestFn)
  await app.listen(3000);
}
bootstrap();
